package com.book.Dao;

import java.io.IOException;

import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.xml.crypto.Data;

public class ModifyBook extends HttpServlet {
	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		
	}
	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		request.setCharacterEncoding("UTF-8");
		response.setCharacterEncoding("UTF-8");
		PrintWriter out=response.getWriter();
		String id=request.getParameter("id");
		String bname=request.getParameter("bname");
		String currPrice=request.getParameter("currPrice");
		String author=request.getParameter("author");
		String press=request.getParameter("press");
		String publishtime=request.getParameter("publishtime");
		String pid=request.getParameter("pid");
		
		   Connection conn=null;
	 	   Statement stm=null;
	 	   ResultSet rs=null;
	 	   String sql="update book set BOOKNAME='"+bname+"',CHUBANSHE='"+press+"',ZUOZHE='"+author+"',BOOKTIME=to_date('"+publishtime+"','yyyy-MM-dd'),PRICE="+currPrice+",FENLEIID="+pid+" where BOOKID="+id+"";
 	   try {
			Class.forName("oracle.jdbc.driver.OracleDriver");
				conn=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:ORCL","scott","tiger");
				stm=conn.createStatement();
				boolean x=stm.execute(sql);
				if(!x){
					out.print("ok");
				}
			} catch (ClassNotFoundException e) {
				e.printStackTrace();
			} catch (SQLException e) {
				out.print("false");
			}
	}
   
}
